
# user defined variables
CC = gcc
PURPLE_CFLAGS = -Wall -pthread -g -pipe -fPIC
PLUGIN_FILENAME = airc.so
PREFIX = /usr/local

PURPLE_LIBS = $(shell pkg-config --libs purple)
PURPLE_CFLAGS += $(CFLAGS) -DPURPLE_PLUGINS -DENABLE_NLS -DPIC
#PURPLE_CFLAGS += $(shell pkg-config --cflags purple)
PURPLE_CFLAGS += -I../pidgin-2.10.4/libpurple -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
PURPLE_CFLAGS += $(shell pkg-config --cflags pidgin)
PURPLE_PLUGIN_DIR = $(PREFIX)/purple-2

all: build/$(PLUGIN_FILENAME)

build/airc.o: airc.c airc.h
	mkdir -p build
	$(CC) $(PURPLE_CFLAGS) -o $@ -c $<

build/airc-cmds.o: airc-cmds.c airc-cmds.h airc.h
	mkdir -p build
	$(CC) $(PURPLE_CFLAGS) -o $@ -c $<

build/airc-parse.o: airc-parse.c airc.h
	mkdir -p build
	$(CC) $(PURPLE_CFLAGS) -o $@ -c $<

build/$(PLUGIN_FILENAME): build/airc.o build/airc-cmds.o build/airc-parse.o
	$(CC) -shared -o $@ $^ $(PURPLE_LIBS)

clean:
	rm -rf build
	rm -f build/$(PLUGIN_FILENAME)

install:
	install -m 0755 -d $(PURPLE_PLUGIN_DIR)
	cp build/$(PLUGIN_FILENAME) $(PURPLE_PLUGIN_DIR)/$(PLUGIN_FILENAME)
